let [pageH, pageW] = [$(window).height(), $(window).width()];
let charts = {};
// 是否显示油量数据
const hasOil = true;
const oilData = {
    "flightId": null,
    "flightDate": null,
    "season": null,
    "flightNo": null,
    "acType": null,
    "departureAirport": null,
    "arrivalAirport": null,
    "totalDistance": null,
    "usedFuelTotal": 318.66,
    "economyFuelTotal": 8.91,
    "avgUsedFuel": 2.42,
    "usedMoneyTotal": 1737003.16,
    "tdQar": null,
    "tdAcars": null,
    "tdCfp": null,
    "td": null,
    "taQar": null,
    "taAcars": null,
    "taCfp": null,
    "ta": null,
    "tdFuelQar": null,
    "tdFuelAcars": null,
    "tdFuelCfp": null,
    "tdFuel": null,
    "taFuelQar": null,
    "taFuelAcars": null,
    "taFuelCfp": null,
    "taFuel": null,
    "flyHours": null,
    "usedFuel": null,
    "hourUsedFuel": null,
    "hourUsedFuelStandard": null,
    "usedFuelStandard": null,
    "economyFuel": null,
    "fulePrice": 5451.00,
    "economyMoney": null,
    "fristPilot": null,
    "fristPilotRatio": null,
    "fristPilotMonty": null,
    "secondPilot": null,
    "secondPilotRatio": null,
    "secondPilotMonty": null,
    "threePilot": null,
    "threePilotRatio": null,
    "threePilotMonty": null,
    "pilotWorkcodes": null,
    "dataErrorFlag": null,
    "flightDateStart": null,
    "flightDateEnd": null,
    "workcode": null,
    "cName": null,
    "flithtFuelPilotList": []
};
//入口预备函数
$(function () {
    //初始化时间日期
    initClock();
    getToken(loadData);
});

//加载数据
function loadData() {
    getMyDate(); //获取日期参数

    getDuty('duty', ['on_duty']); //值班人信息

    getIncome('income', ['income_with_charter', 'site_income_with_charter', 'hour_income_with_charter']); //昨日收入，座公里收入，小时收入
    getIncomeMon('income_mon', ['mon_income_with_charter']); //月累计收入
    getProfit1('profit1', ['all_profit', 'site_mul_cost', 'hour_cost']); //昨日利润，座公里成本，小时成本
    getProfit2('profit2', ['all_cost']); //月累计成本
    getCus('cus', ['cus_cnt']); //昨日旅客量
    getVip('vip', ['vip_num']); //昨日旅客量VIP
    getWgt('wgt', ['wgt']); //昨日货运量
    getMemberLevel('member_level'); //旅客级别

    getMapData('map', ['cus_site_ratio', 'avg_pri_with_charter']); //昨日客座率和平均票价
    getMapLines(); //地图上的航班状态
    getSafe('safe', ['fly_days', 'act_fly_hour', 'flight_move_cnt']); //安全分析
    getSafe1('safe1', ['CNT']); //本周二级（含）以上超限事件

    todayFlightPlan(); //今日计划航班
    getAbnormal('abnormal');
    // getOil('oil', ['ECONOMY_FUEL', 'fuel_cost', 'PRICE', 'used_Fuel', 'USED_FUEL_HOUR']); //当前航班正常率、备降、取消、延误
    getOil('oil', ['usedFuelTotal', 'avgUsedFuel', 'economyFuelTotal', 'fulePrice', 'usedMoneyTotal']); //当前航班正常率、备降、取消、延误
}

// 今日计划航班
function todayFlightPlan() {
    getFoc1('foc1', ['TOTAL_COUNT', 'FLIGHTED_COUNT', 'PLAN_FLIGHT_COUNT']); //今日计划，已执行，应执行
    getFoc3('foc3', ['act_fly_hour', 'daily_use_ratio']); //昨日飞行时间，昨日利用率
    getFoc2('foc2', ['NORMAL_RATE', 'BF_COUNT', 'CANCEL_COUNT', 'DELAY_COUNT']); //当前航班正常率、备降、取消、延误
}

/**
 * jquery get请求的公共选项
 * @param sqlCode 用于拼接sql语句的标识代码
 * @param ids 要绑数的dom元素id们
 * @return {{url: string, data: {dataType: string, params: string}, beforeSend: beforeSend, success: success}}
 */
function getJqOpt(sqlCode, ids) {
    return {
        url: clientUrl,
        data: {
            dataType: 'hl_qdhk_yyfxpt_' + sqlCode,
            params: `dataDt::${yesterdayDate}`
        },
        dataType: 'json',
        beforeSend(request) {
            setHeader(request);
        },
        success(data) {
            if (data.data.qdhk.length === 0) {
                console.warn(sqlCode + ' 获取的数据为空!', data)
            } else {
                jqAjaxSuccess(data, ids);
            }
        }
    }
}

/**
 * 绑数公用遍历方法
 * @param data ajax返回的数据
 * @param ids 要绑数的dom元素id们
 */
function jqAjaxSuccess(data, ids) {
    ids.forEach(function (id) {
        $("#" + id).text(hasVal(data.data.qdhk[0][id]))
    });
}

// 值班人信息
function getDuty(sqlCode, ids) {
    $.get($.extend(getJqOpt(sqlCode, ids), {
        data: {
            dataType: 'hl_qdhk_yyfxpt_' + sqlCode,
        }
    }));

}

// 昨日收入，座公里收入，小时收入
function getIncome(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {
        success: function (data) {
            jqAjaxSuccess(data, ids);
            let yesterdayDataIncome = data.data.qdhk[0].income_with_charter;
            let target = data.data.qdhk[0].target;
            let $icon = $("#income_with_charter").next().next();
            // let beforeYesterdayDataIncome = beforeYesterdayData.data.qdhk[0].income_with_charter;
            if (yesterdayDataIncome > target) {
                $icon.attr('class', 'icon-increase');
            } else if (yesterdayDataIncome < target) {
                $icon.attr('class', 'icon-decrease');
            } else {
                $icon.attr('class', 'icon-flat');
            }
        }
    }));
}

// 月累计收入
function getIncomeMon(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {}));
}

// 昨日利润，座公里成本，小时成本
function getProfit1(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {}));
}

// 月累计成本
function getProfit2(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {}));
}

// 昨日旅客量
function getCus(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {}));
}

// 昨日旅客VIP
function getVip(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {}));
}

//旅客级别
function getMemberLevel(sqlCode) {
    $.get($.extend(true, getJqOpt(sqlCode), {
        success: function (data) {
            let seriesData = [];
            data.data.qdhk.forEach(function (item) {
                seriesData.push({
                    name: item.member_level,
                    value: parseFloat(item.cus_cnt),
                })
            });
            ec01_circle_getMemberLevel_d(seriesData);
        }
    }));
}

//旅客级别 - 环形图
function ec01_circle_getMemberLevel_d(seriesData) {
    let chart = echarts.init($("#ec01_circle_passengerLevel")[0]);
    charts.ec01_circle_passengerLevel = chart;
    chart.setOption(com_circle);
    chart.setOption({
        title: {
            text: '团散客人数占比',
            textStyle: {
                color: '#fff',
                fontSize: 16 * bodyScale
            },
            x: 'center',
            y: 'bottom'
        },
        series: [{
            startAngle: 0,
            center: ['50%', '45%'],
            label: {
                height: 60 * bodyScale,
                formatter: '{b}\n{c}%',
                fontSize: 18 * bodyScale
            },
            labelLine: {length: 24 * bodyScale},
            data: seriesData
        }].map(function (item, index) {
            return $.extend(true, {}, com_circleSeries, item);
        })
    })
}

// 昨日货运量
function getWgt(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {}));
}

// 昨日客座率和平均票价
function getMapData(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {
            success: function (data) {
                jqAjaxSuccess(data, ids);
                $("#cus_site_ratio").str2NumFixed(2, 2)
            }
        })
    );
}

// 地图上的航班状态
function getMapLines() {
    let chart = echarts.init($("#ec02_map_airLines")[0]);
    charts.ec02_map_airLines = chart;
    // 画地图
    $.get('assets/data/Asia.json', function (mapJson) {
        echarts.registerMap('Asia', mapJson, {});
        chart.setOption({
            tooltip: {
                show: false
            },
            geo: {
                map: 'Asia',
                //控制台获取当前的位置和缩放比
                center: [104.65124914515744, 33.70816892991341],
                zoom: 1.33,
                roam: true,
                itemStyle: {
                    areaColor: '#1a46a7',
                    borderColor: '#407cd4'
                },
                emphasis: {
                    label: {
                        show: false,
                        color: '#fff'
                    },
                    itemStyle: {
                        areaColor: '#1a46a7'
                    },
                },
            },
            // series由多层构成：【1-基地；2-所有当天航段起落点（去重）；3-规划航线；4-实时航线；5-当前航段的起落点（动态）；6~n-实时飞机的位置(后面合并进来)】
            series: [{ // 基地
                type: 'scatter',
                coordinateSystem: 'geo',
                zlevel: 2,
                symbol: star,
                symbolSize: 25 * bodyScale,
                itemStyle: {
                    color: '#d40505',
                },
                data: [{
                    name: '青岛',
                    value: [120.225, 36.160]
                }/*, {name: '烟台',value: [120.7397, 37.5128]
                }*/]
            }, { // 所有当天航段起落点（去重）
                type: 'scatter',
                coordinateSystem: 'geo',
                zlevel: 1,
                symbolSize: 8 * bodyScale,
                itemStyle: {
                    color: '#010237',
                },
                data: []
            }, { // 当前航段的起落点（动态）
                type: 'effectScatter',
                coordinateSystem: 'geo',
                zlevel: 5,
                symbolSize: 4 * bodyScale,
                itemStyle: {
                    color: '#010237',
                },
                rippleEffect: {
                    brushType: 'stroke',
                    scale: 10 * bodyScale,
                },
                data: [],
            }, { // 规划航线
                type: 'lines',
                zlevel: 3,
                symbolSize: 15 * bodyScale,
                polyline: true,
                lineStyle: {
                    color: '#ff6475',
                    width: 2.5 * bodyScale,
                    opacity: 0.6,
                    curveness: 0.2
                },
                data: []
            }, { // 实际航线
                type: 'lines',
                zlevel: 4,
                symbolSize: 15 * bodyScale,
                polyline: true,
                effect: { //小飞机
                    show: false,
                    color: '#4B60ff',
                    period: 6,
                    trailLength: 0,
                    symbol: fighter,
                    symbolSize: 12,
                    constantSpeed: 15,
                    // loop: false
                },
                lineStyle: {
                    color: '#00f9ff',
                    width: 2.5 * bodyScale,
                    opacity: 0.9,
                },
                data: []
            }]
        });
    });
    ec02_map_airLines_a(chart);
}

// 地图上航线的ajax
function ec02_map_airLines_a(chart) {
    //今天所有航段的端点
    $.get($.extend(true, getJqOpt('map2'), {
        success: function (data) {
            let todayAllPoints = [];
            data.data.qdhk.forEach(function (item) {
                todayAllPoints.push({
                    name: item.CITY_CH_NAME,
                    value: [item.LONGITUDE / 1e3, item.LATITUDE / 1e3]
                })
            });
            let series = chart.getOption().series;
            series[1].data = todayAllPoints;
            chart.setOption({
                series: series
            })
        }
    }));
    $.when( //获取实时航班和规划路线
        $.get({
            url: 'http://172.16.3.169:9999/api/v1/common/interface/getByDataType?dataType=hl_qdhk_yyfxpt_map_shshhx',
            dataType: 'json'
        }),
        $.get({ //获取实时航线id
            url: 'http://172.16.2.142:11080/flight/getRiskCfpJsonp',
            dataType: 'jsonp',
        }),
        $.get({url: clientUrl + '?dataType=hl_qdhk_yyfxpt_map1', dataType: 'json'}),
    ).done(function (allLinesDataNow, allLinesData) {
        let obj = getAllLinesChartDataNow(allLinesDataNow[0], allLinesData[0], chart);

    })
}

// 获取实时航线
function getAllLinesChartDataNow(data, allLinesData, chart) {
    data = data.data.qdhk;
    let allLinesDataNow = [];
    let lineIds = [];
    let orderData = [];//按航班和时间整理数据
    let flyingEnthesis = [];
    let ajaxArr = [];//使用Promise
    data.forEach(function (item, index) {
        lineIds.push(item.FLIGHT_ID);
        flyingEnthesis.push({ // 每条航线的起落点
            name: item.DEPARTURE_AIRPORT,
            value: [item.LAT_DEPT / 1e3, item.LON_DEPT / 1e3]
        }, {
            name: item.ARRIVAL_AIRPORT,
            value: [item.LAT_ARRV / 1e3, item.LON_ARRV / 1e3]
        });
        ajaxArr.push($.get({
            url: `http://172.16.2.191:8089/v1/acars/listPosByFlightIdJsonp?flightId=${item.FLIGHT_ID}`,
            dataType: 'jsonp',  // 请求方式为jsonp
        }));
    });
    Promise.all(ajaxArr).then(results => {
        results.forEach(line => {
            let arr = [];
            line.forEach(point => {
                arr.push([point.lon.slice(1) / 1e6, point.lat.slice(1) / 1e6])
            });
            allLinesDataNow.push(arr)
        });
        // 如果航线目前只有一个点，则绘制线会报错
        allLinesDataNow.map(function (item) {
            if (item.length < 2) {
                item.push(item[0])
            }
            return item;
        });

        let series = chart.getOption().series;
        series[2].data = flyingEnthesis;
        chart.setOption({series: series});
        allLinesData = getAllLinesChartData(lineIds, allLinesData);
        ec02_map_airLines_d(allLinesDataNow, allLinesData, chart);

    })
}

// 获取规划航线
function getAllLinesChartData(lineIds, data) {
    let allLinesData = [];
    // 双层遍历，是为了让规划和实时的路线数据对应
    lineIds.forEach(function (lineId) {
        data.forEach(function (item, index) {
            if (item.cfpType === 'MAIN' && lineId === item.flightId) {
                let points = [];
                item.pointList.forEach(function (point) {
                    let [longitudeStr, latitudeStr] = [point.longitude, point.latitude];
                    if (longitudeStr && latitudeStr) {
                        let [longitude, latitude] = [longitudeStr.slice(1) / 1000, latitudeStr.slice(1) / 1000];
                        if (!isNaN(longitude + latitude)) {
                            points.push([longitude, latitude])
                        }
                    }
                });
                allLinesData.push(points)
            }
        });
    });
    return allLinesData;
}

/**
 * 地图上的航线 - 绘制线和点
 * @param allLinesDataNow
 * @param allLinesData
 // * @param arrivalAirports
 * @param chart
 */
function ec02_map_airLines_d(allLinesDataNow, allLinesData, chart) {
    let toPoints = allLinesData.map(function (item) {
        return item[item.length - 1]
    });
    // 飞机实时位置点们
    let nowPositionObj = allLinesDataNow.map(function (item, index) {
        return {
            type: 'scatter',
            coordinateSystem: 'geo',
            zlevel: 6,
            itemStyle: {
                color: '#00f9ff',
            },
            symbol: fighter,
            symbolSize: 21 * bodyScale,
            symbolRotate: function () {
                let [deltaY, deltaX] = [toPoints[index][1] - item[item.length - 1][1], toPoints[index][0] - item[item.length - 1][0]]; // 指向规划路线的最后一个有效点
                let atan = deltaY / deltaX;
                let deg = Math.atan(atan) / Math.PI * 180;
                if (deltaX < 0) { //第二三象限
                    deg += 180
                }
                return deg - 90; //echarts的0度是数值朝上的
            }(),
            data: [item[item.length - 1]],
        }
    });
    let series = chart.getOption().series;
    series[3].data = allLinesData;
    series[4].data = allLinesDataNow;
    series.length = 5;
    chart.setOption({
        series: series.concat(nowPositionObj)
    });
}

// 安全
function getSafe(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {
        success: function (data) {
            jqAjaxSuccess(data, ids);
            $("#act_fly_hour").str2NumFixed(0)
        }
    }));
}

// 安全
function getSafe1(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {}));
}

// 今日计划，已执行，应执行
function getFoc1(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {
        data: {
            params: `dataDt::${todayDate}`
        },
    }));
}

// 昨日飞行时间，昨日利用率
function getFoc3(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {
        success: function (data) {
            if (data.data.qdhk.length === 0) {
                console.warn(sqlCode + ' 获取的数据为空!', data)
            } else {
                ids.forEach(function (id) {
                    if (id === 'act_fly_hour') {
                        $("#foc3_" + id).text(hasVal(data.data.qdhk[0][id]))
                    } else {
                        $("#" + id).text(hasVal(data.data.qdhk[0][id]))
                    }
                });
                $("#foc3_act_fly_hour").str2NumFixed(0)
                $("#daily_use_ratio").str2NumFixed(2)
            }

        }
    }));
}

// 当前航班正常率、备降、取消、延误
function getFoc2(sqlCode, ids) {
    $.get($.extend(true, getJqOpt(sqlCode, ids), {
        data: {
            params: `dataDt::${todayDate}`
        },
        success: function (data) {
            ids.forEach(function (id) {
                $("#" + id).text(data.data.qdhk[0][id])
            });
            $("#NORMAL_RATE").str2NumFixed(0, 2, '%')
        }
    }));
}

// 不正常航班
function getAbnormal(sqlCode) {
    $.get($.extend(true, getJqOpt(sqlCode), {
        success: function (data) {
            let seriesData = [{data: []}, {data: []}];
            data.data.qdhk.forEach(function (item) {
                seriesData[0].data.push(item.abnormal_flight * 100)
                seriesData[1].data.push(item.yj * 100)
            });
            ec03_line_abnormalFlight_d(seriesData);
        }
    }));
}

// 不正常航班 - 折线图
function ec03_line_abnormalFlight_d(seriesData) {
    let last7DaysLabel = {date: [], day: []};
    let now = new Date();
    let oneDay = 24 * 3600 * 1000;

    function getMonAndDate(timeObj) {
        let [mon, date] = [timeObj.getMonth() + 1,
            timeObj.getDate()];
        return `${mon}-${date > 9 ? date : "0" + date}`;
    }

    for (let i = 7; i > 0; i--) {
        last7DaysLabel.date.push(getMonAndDate(new Date(now - i * oneDay)));
        last7DaysLabel.day.push('周' + '日一二三四五六'.split('')[new Date(now - i * oneDay).getDay()])
    }

    let chart = echarts.init($("#ec03_line_abnormalFlight")[0]);
    charts.ec03_line_abnormalFlight = chart;
    chart.setOption(com_line);
    chart.setOption({
        grid: {
            left: '12%',
            right: '8%',
            top: '12%',
            bottom: '16%'
        },
        xAxis: {
            data: last7DaysLabel.date,
            axisLabel: {
                interval: 0,
            }
        },
        yAxis: {
            axisLabel: {
                // interval: 2,//不知为啥不起作用
                formatter: function (value, index) {
                    if (index % 2 === 0) {
                        return value.toFixed(0) + '%'
                    }
                }
            }
        },
        tooltip: {
            show: true,
            formatter: function (param) {
                return (last7DaysLabel.day)[param[1].dataIndex] + '</br>'
                    + '公司原因占比: ' + parseFloat(param[0].value).toFixed(2) + '%</br>'
                    + '限制: ' + param[1].value + '%';
               /*  return '周' + '一二三四五六日'.split('')[parseInt(param[0].axisValue) - 1] + '</br>'
                     + '公司原因占比: ' + parseFloat(param[0].value).toFixed(2) + '%</br>'
                     + '限制: ' + param[1].value + '%'*/
            }
        },
        series: seriesData.map(function (item, index) {
            return $.extend(true, {}, com_lineSeries, item);
        })
    })
}

// 昨日油量统计
function getOil(sqlCode, ids) {
    if (hasOil) {
        $.get({
            url: `http://172.16.2.82:8080/flightFuel/getBIPilotFuelList.do?flightDateStart=${beforeYesterdayDateWithHyphen}&flightDateEnd=${beforeYesterdayDateWithHyphen}`,
            dataType: 'jsonp',  // 请求方式为jsonp
            // jsonp: 'callback',
            timeout: 5000,
            success(data) {
                ids.forEach(function (id) {
                    $("#" + id).text(hasVal(data[id]))
                });
                $('#usedMoneyTotal').str2NumFixed(2, -4)
            },
            error(data) {
                data = oilData;
                ids.forEach(function (id) {
                    $("#" + id).text(hasVal(data[id]))
                });
                $('#usedMoneyTotal').str2NumFixed(2, -4)
            }
        });
    } else {
        $('.r-b strong').text('-')
    }
}

//获取天气情况
function getWeather(currTime) {
    // 官方文档 http://www.heweather.com/douments/api/s6/weather-forecast
    $.get("https://free-api.heweather.com/s6/weather/forecast?location=青岛&key=7e07c4303b4841e6b1595dca70f9d4a7", function (data) {
        let temperatureTxt = '';
        let daily_forecast = data.HeWeather6[0].daily_forecast[0];
        // console.warn(data.HeWeather6[0].status)
        let [code, txt] = ['', ''];
        if ((currTime.getHours() >= 6) && (currTime.getHours() < 18)) {
            code = daily_forecast.cond_code_d;
            txt = daily_forecast.cond_txt_d;
            temperatureTxt = daily_forecast.tmp_min + "℃~" + daily_forecast.tmp_max + "℃";
        } else {
            code = daily_forecast.cond_code_n;
            txt = daily_forecast.cond_txt_n;
            temperatureTxt = daily_forecast.tmp_max + "℃~" + daily_forecast.tmp_min + "℃";
        }
        $("#weather").text(txt);
        $("#temperature").text(temperatureTxt);
        $("#weatherIcon").css('background-image', `url("https://cdn.heweather.com/cond_icon/${code}.png")`);
    })
}

// 获取昨天前天
function getMyDate() {
    let today = new Date();
    let yesterday = new Date(today - 24 * 3600 * 1000);
    let beforeYesterday = new Date(today - 48 * 3600 * 1000);
    [todayDate, yesterdayDate, beforeYesterdayDate, beforeYesterdayDateWithHyphen]
        = [DateFormatter(today).dateStrNoHyphen, DateFormatter(yesterday).dateStrNoHyphen, DateFormatter(beforeYesterday).dateStrNoHyphen, DateFormatter(beforeYesterday).dateStrWithHyphen];
    // 设置油量标题中的前天日期
    let beforeYesterdayObj = DateFormatter(beforeYesterday);
    let [mon, date] = [beforeYesterdayObj.mon, beforeYesterdayObj.date];
    $(".r-b h4").append(`(${mon}月${date}日)`)
}

//初始化时间日期
function initClock() {
    setTimeout(function () {
        let currTime = new Date();
        let [year, mon, date, hour, min, sec, milliSec] = [
            currTime.getFullYear(),
            currTime.getMonth() + 1,
            currTime.getDate(),
            currTime.getHours(),
            currTime.getMinutes(),
            currTime.getSeconds(),
            currTime.getMilliseconds()
        ];
        let time = `${hour}:${min > 9 ? min : "0" + min}:${sec > 9 ? sec : "0" + sec}`;
        let dateStr = `${year}-${mon > 9 ? mon : "0" + mon}-${date > 9 ? date : "0" + date}`;
        $(".time").text(time);
        $(".date").text(dateStr);
        // 调天气预报接口——天气不需要了
        // if (!hasGetWeather) {
        // getWeather(currTime);
        // hasGetWeather = true;
        // } else {
        if (min % getWeatherPeriod === 0 && (sec === 0 || sec === 30) && milliSec < 500) {
            // getWeather(currTime);
            ec02_map_airLines_a(charts.ec02_map_airLines);
            todayFlightPlan();
        }
        // }

        if (hour === 0 && min === 0 && sec === 0 && milliSec < 500) { //过夜
            getDate();
            loadData();
        }
        initClock();
    }, 500)
}




